<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../react18/react.development.js"></script>
  <script src="../react18/react-dom.development.js"></script>
  <script src="../react18/babel.min.js"></script>
</head>

<body>
  <div id="app"></div>
  <script type="text/babel">
  
class App extends React.Component{
  state ={
    name:'高高'
  }
  render(){
    const {name}=this.state
    return(
      <div>
        <button onClick ={this.handle}>点击</button>
        <h1>我是霸霸{name}</h1>
        <Content a={name}/>
      </div>
    )
  }
  handle=()=>{
    this.setState({name:'小高'})
  }
}

function Content (props){
  console.log(props)//父组件在使用子组件时，在子组件中添加的属性，直接在函数式组件的形参可以接收到添加的属性和属性值所组成的对象
  const{a} = props
  return (
    <h2>我是小盆友{a}</h2>
  )
}

const root = ReactDOM.createRoot(document.getElementById('app')).render(<App/>)
  </script>
</body>

</html>